# -*- coding: utf-8 -*-
# flake8: noqa
# import os
# from ajia08.ajia08.utils.qiniuyun.qiniu_storage import storage

import os
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'ajia08.ajia08.settings.settings')
from ajia08.ajia08.apps.test_xianghaiyang.models import House
# dir_path = '/home/ubuntu/Document/七牛云'
# oringin_path = '/home/ubuntu/Document/七牛云'
# file_list = os.listdir(dir_path)
# print(file_list)
# list01 = []
# for files in file_list:
#     file_path_list = oringin_path + files
#     list01.append(file_path_list)
# print(list01)
# image_url = []
# for pics in list01:
#     image_url.append(storage(pics))
# print(image_url)
# list01 = ['',
#  '',
#  'FpMYdJsJaYj1bM9VqP3RHq9SNd3o',
#  'FtQNhCKtSPqpwXIy8FigceeYXBaV',
#  'Fg4jxcFAUSpLxjRScwgejr3mQFJV',
#  'FmCnmzWoQuPogf1U5gXTKU8DR6Xx',
#  'FvdLIEWm5gXFZA13LKXOBn18MCWm',
#  'FhWfYh4Y1aue9z1F1lKwi0ih3SKh',
#  'FmNjsB9S5yizmaQI7QgQU8HXVETd',
#  'FvcYZYyY0-GTmKIzEhjHkkD-or0t',
#  'Fo0iDBjXNPLHb0YjHx11lVOWDIzC',
#  'Foykfu5nQHEaO0ep-N-PhWaeoVoL',
#  'Fq0XIT7WETqJg7lN4ueR98m8wR0r',
#  'FgyKACbONQvJmRG4PZLnSq27YZxN',
#  'FgiRDuwVMH9is0h2EchQuKBmOb2e',
#  'FrK9pNF1q9r5Hh_b_MKShByxplvT']
# list01 = ['FsFYi6s3qOACYN3ed8glELSADtWl',
#  'FmkoNkaZgBAIZN2sCM46RY1ihzBD',
#  'FpMYdJsJaYj1bM9VqP3RHq9SNd3o',
#  'FtQNhCKtSPqpwXIy8FigceeYXBaV',
#  'Fg4jxcFAUSpLxjRScwgejr3mQFJV',
#  'FmCnmzWoQuPogf1U5gXTKU8DR6Xx',
#  'FvdLIEWm5gXFZA13LKXOBn18MCWm',
#  'FhWfYh4Y1aue9z1F1lKwi0ih3SKh',
#  'FmNjsB9S5yizmaQI7QgQU8HXVETd',
#  'FvcYZYyY0-GTmKIzEhjHkkD-or0t',
#  'Fo0iDBjXNPLHb0YjHx11lVOWDIzC',
#  'Foykfu5nQHEaO0ep-N-PhWaeoVoL',
#  'Fq0XIT7WETqJg7lN4ueR98m8wR0r',
#  'FgyKACbONQvJmRG4PZLnSq27YZxN',
#  'FgiRDuwVMH9is0h2EchQuKBmOb2e',
#  'FrK9pNF1q9r5Hh_b_MKShByxplvT']

# for image_url in list01:
#     print(str(image_url))

i = 10
for image_url in list01:
    House.objects.create(title= i, price=100, area_id=1, address='10号',
                         room_count=5, acreage=100, unit='两室两厅', capacity=5,
                         beds='双人床',
                         deposit=1000,
                         min_days=1,
                         max_days=0, facility=[1, 2, 3, 4, 5],
                         user_id=4, image_url= str(image_url))
    i +=1

insert into tb_house(title, price,address, room_count, acreage, unit, capacity,beds,deposit,min_days, max_days, facility, user_id, image_url)
values(10,100,1 '10号', 5, 100,'两室两厅', 5, '双人床',1000, 1,0,[1, 2, 3, 4, 5], 4, 'FsFYi6s3qOACYN3ed8glELSADtWl')

# from qiniu import Auth, put_file, etag
# import qiniu.config
# access_key = 'uWLFSZJjbn-hrnac5JDUhZcnAaWk849VD8BIWlIv'
# secret_key = 'fBDtDHYWkU9p7BX3ub2-t-NsJLoia6H9sCtVz4yF'
#
# q = Auth(access_key, secret_key)
#
# bucket_name = 'ihome08'
#
# key = 'ihome09.jpg'
#
#
# token = q.upload_token(bucket_name, key, 3600)
#
# localfile = '/home/ubuntu/Document/七牛云/9.jpg'
#
# ret, info = put_file(token, key, localfile)
# print(info)
# assert ret['key'] == key
# assert ret['hash'] == etag(localfile)
